﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

public partial class Sys_regapprove : System.Web.UI.Page
{
    PM.PMSys.account Account = new PM.PMSys.account();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GridViewbind();
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        GridViewbind();
    }
    protected void GridViewbind()
    {
        StringBuilder sqlstrfield=new StringBuilder();
        getField(ref sqlstrfield);
        PM.Code.Web.controlbind.BindGridViewPublicProc(GridView1,AspNetPager1,"Sys_Account","id",sqlstrfield.ToString(),"id desc","status=0",true);
    }
    protected void getField(ref StringBuilder sqlstrfield)
    {
        sqlstrfield.Append("id,tid,name,sex,title,field,depart,cellphone,regdatetime,case usertype when 1 then '普通用户' when 2 then '学院管理员' ");
        sqlstrfield.Append("when 3 then '项目管理员' when 4 then '系统管理员' else '其他' end as usertype");
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName=="Allow")
        {
            Account.StatusChange(int.Parse(e.CommandArgument.ToString()),true);
            //PM.Code.Web.alertmessage.ResponseScript("window.location.href='regapprove.aspx'");
            GridViewbind();
        } 
        else if(e.CommandName=="Deny")
        {
            Account.StatusChange(int.Parse(e.CommandArgument.ToString()),false);
            //PM.Code.Web.alertmessage.ResponseScript("window.location.href='regapprove.aspx'");
            GridViewbind();
        }
        else
            PM.Code.Web.alertmessage.ShowMsg("系统发生异常，操作失败！请联系系统管理员……");
    }
}
